package com.futurelight.recipes.ui.fragment;

import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.futurelight.recipes.R;
import com.futurelight.recipes.adapter.IngredientAdapter;
import com.futurelight.recipes.model.Result;


public class IngredientFragment extends Fragment {
    private final Result result;
    private View rootView;

    public IngredientFragment(Result result) {
        this.result = result;
    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.fragment_ingredient, container, false);
        initView();
        return rootView;
    }

    private void initView() {
        RecyclerView recyclerView = rootView.findViewById(R.id.ingredient_recycler_view);
        IngredientAdapter ingredientAdapter = new IngredientAdapter();
        ingredientAdapter.setIngerdients(result.extendedIngredients);
        recyclerView.setAdapter(ingredientAdapter);
        recyclerView.setLayoutManager(new GridLayoutManager(getContext(),2,GridLayoutManager.HORIZONTAL,false));

    }
}